load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("fbcode_entropy_wardens_folly")

cpp_library(
    name = "barrier",
    srcs = ["Barrier.cpp"],
    headers = ["Barrier.h"],
    deps = [
        "//folly:scope_guard",
        "//folly/lang:new",
    ],
    exported_deps = [
        ":core",
    ],
    external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "core",
    srcs = [
        "Future.cpp",
        "HeapTimekeeper.cpp",
        "Promise.cpp",
        "ThreadWheelTimekeeper.cpp",
    ],
    headers = [
        "Future.h",
        "Future-inl.h",
        "Future-pre.h",
        "HeapTimekeeper.h",
        "Promise.h",
        "Promise-inl.h",
        "Retrying.h",
        "ThreadWheelTimekeeper.h",
        "WTCallback.h",
    ],
    deps = [
        "//folly:likely",
        "//folly:singleton",
        "//folly/container:intrusive_heap",
        "//folly/lang:safe_assert",
        "//folly/portability:gflags",
        "//folly/synchronization:distributed_mutex",
        "//folly/synchronization:relaxed_atomic",
        "//folly/synchronization:saturating_semaphore",
        "//folly/synchronization:wait_options",
        "//folly/system:thread_name",
    ],
    exported_deps = [
        ":portability",
        "//folly:chrono",
        "//folly:optional",
        "//folly:portability",
        "//folly:random",
        "//folly:scope_guard",
        "//folly:traits",
        "//folly:try",
        "//folly:unit",
        "//folly:utility",
        "//folly/container:foreach",
        "//folly/coro:traits",
        "//folly/detail:async_trace",
        "//folly/executors:drivable_executor",
        "//folly/executors:executor_with_priority",
        "//folly/executors:global_executor",
        "//folly/executors:inline_executor",
        "//folly/executors:queued_immediate_executor",
        "//folly/executors:timed_drivable_executor",
        "//folly/fibers:core",
        "//folly/functional:invoke",
        "//folly/futures/detail:core",
        "//folly/futures/detail:types",
        "//folly/io/async:async_base",
        "//folly/lang:exception",
        "//folly/lang:pretty",
    ],
)

cpp_library(
    name = "future_splitter",
    headers = ["FutureSplitter.h"],
    exported_deps = [
        ":core",
        ":shared_promise",
        "//folly/lang:exception",
    ],
)

cpp_library(
    name = "futures",
    exported_deps = [
        ":barrier",  # @manual
        ":core",  # @manual
        ":future_splitter",  # @manual
        ":shared_promise",  # @manual
        "//folly/executors:inline_executor",  # @manual
        "//folly/executors:manual_executor",  # @manual
        "//folly/executors:queued_immediate_executor",  # @manual
        "//folly/executors:scheduled_executor",  # @manual
    ],
)

cpp_library(
    name = "manual_timekeeper",
    srcs = ["ManualTimekeeper.cpp"],
    headers = ["ManualTimekeeper.h"],
    deps = [
        "//folly/synchronization:atomic_util",
    ],
    exported_deps = [
        "//folly:synchronized",
        "//folly/futures:core",
    ],
)

cpp_library(
    name = "portability",
    headers = ["Portability.h"],
    exported_deps = [
        "//folly:portability",
    ],
)

cpp_library(
    name = "shared_promise",
    srcs = ["SharedPromise.cpp"],
    headers = [
        "SharedPromise.h",
        "SharedPromise-inl.h",
    ],
    exported_deps = [
        ":core",
        "//folly:portability",
        "//folly/executors:inline_executor",
        "//folly/lang:exception",
    ],
)

cpp_library(
    name = "cleanup",
    headers = ["Cleanup.h"],
    exported_deps = [
        "//folly/futures:core",
    ],
    exported_external_deps = [
        "glog",
    ],
)
